Sanity Check for MNIST HDF5

We want to make sure that neon can correctly load the data from the HDF5 file.


In [32]:
from neon.data import HDF5Iterator  # Neon's HDF5 data loader
from neon.backends import gen_backend
import numpy as np

In [5]:
be = gen_backend(backend='cpu', batch_size=1)

In [6]:
outFilename = 'mnist_test.h5'  # The name of our HDF5 data file

In [7]:
train_set = HDF5Iterator(outFilename)

In [8]:
train_set.get_description()


Out[8]:
{'config': {'hdf_filename': 'mnist_test.h5', 'name': 'HDF5Iterator_1'},
 'type': 'neon.data.hdf5iterator.HDF5Iterator'}

In [10]:
train_set.ndata   # Number of patients in our dataset


Out[10]:
10000

In [11]:
train_set.lshape   # DICOM image tensor (C x H x W x D)


Out[11]:
(1, 28, 28)

In [17]:
from matplotlib import pyplot as plt
%matplotlib inline

In [37]:
plt.imshow(train_set.inp[0,:].reshape(28,28), cmap=cm.gray);



In [29]:
i = 0
for x, t in train_set:
    
    print(i)
    print(x)
    plt.imshow(x.get().reshape(28,28), cmap=cm.gray); 
    
    i += 1
    break


0
CPUTensor(base 0x104421990) name:None shape:(784, 1) dtype:float32 strides:(4, 4) is_c_contiguous:True

In [ ]: